package tool

import "github.com/sqids/sqids-go"

var sq *sqids.Sqids

func init() {
	sq, _ = sqids.New(sqids.Options{
		MinLength: 8,
		Alphabet:  "FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DmLGIJOgb5ZEwaU04Tzt9fHQrqSVKdpi",
	})
}

func GetSQID(input int64) string {
	id, _ := sq.Encode([]uint64{uint64(input)})
	return id
}

func DecodeSQID(id string) int64 {
	ids := sq.Decode(id)
	if len(ids) == 0 {
		return 0
	}
	return int64(ids[0])
}
